package com.marketingManagement.controller;

import com.eight.pojo.TbAdvertise;
import com.eight.pojo.TbCustomerIssues;
import com.eight.vo.ComResult;
import com.marketingManagement.service.impl.advertiseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;

/**
 * @author caoch
 * @since 2023/2/28 20:11
 **/
@RestController
@RequestMapping("/marketingManagement")
public class advertiseController {
	@Autowired
	private advertiseServiceImpl advertiseService;
	@RequestMapping("addAdvertise")
	public ComResult addAdvertise(@RequestBody TbAdvertise advertise) {
		advertise.setStartTime(LocalDateTime.now());
		advertise.setEndTime(LocalDateTime.now().plusDays(3));
		advertise.setStatus(0);
		advertise.setClickCount(0);
		advertise.setOrderCount(0);
		return new ComResult(2000,"success",advertiseService.addAdvertise(advertise));
	}
	@RequestMapping("updateAdvertise")
	public ComResult updateAdvertise(@RequestBody TbAdvertise advertise) {
		return new ComResult(2000,"success",advertiseService.updateAdvertise(advertise));
	}
	@RequestMapping("removeAdvertise/{id}")
	public ComResult removeAdvertise(@PathVariable int id) {
		return new ComResult(2000,"success",advertiseService.removeAdvertise(id));
	}
	@RequestMapping("selectAdvertise")
	public ComResult selectAdvertise(@RequestParam(defaultValue = "1")Integer currentPage,
	                                      @RequestParam(defaultValue = "5")Integer pageSize,
	                                      @RequestBody TbAdvertise advertise ) {
		return new ComResult(2000,"success",advertiseService.selectAdvertise(currentPage, pageSize, advertise));
	}
}
